package com.example.rpAdapter.web.admin;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.common.annotation.ResponseResult;
import com.example.rpclient.api.IAwardService;
import com.example.rpclient.dto.AwardAddCmd;
import com.example.rpclient.dto.AwardUpdateCmd;
import com.example.rpclient.dto.data.AwardVo;
import com.example.rpclient.dto.query.AwardListByParamQuery;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@Slf4j
@AllArgsConstructor
@ResponseResult
@RequestMapping("/admin/v1/award")
public class AdminAwardController {

    private final IAwardService awardService;

    @PostMapping("/add")
    public AwardVo add(@Validated @RequestBody AwardAddCmd cmd) {
        return awardService.add(cmd);
    }

    @PostMapping("/update")
    public AwardVo update(@Validated @RequestBody AwardUpdateCmd cmd) {
        return awardService.update(cmd);
    }

    @GetMapping("/{id}")
    public AwardVo one(@PathVariable(name = "id") Long id) {
        return awardService.one(id);
    }

    @PostMapping("/page")
    public IPage<AwardVo> page(@RequestBody AwardListByParamQuery query) {
        return awardService.page(query);
    }


}
